package com.flyco.modules.oms.entity;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import com.flyco.poi.excel.annotation.Excel;

/**
 * @Description: 订单跟踪
 * @Author: flyco
 * @Date: 2020-03-27
 * @Version: V1.0
 */
@Data
@TableName("oms_order_trace")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "oms_order_trace对象", description = "订单跟踪")
public class OmsOrderTrace {

    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "id")
    private Long id;
    /**
     * 订单id
     */
    @Excel(name = "订单id", width = 15)
    @ApiModelProperty(value = "订单id")
    private String orderId;
    /**
     * 快递单号
     */
    @Excel(name = "快递单号", width = 15)
    @ApiModelProperty(value = "快递单号")
    private String traceNo;
    /**
     * 标签
     */
    @Excel(name = "标签", width = 15)
    @ApiModelProperty(value = "标签")
    private String label;
    /**
     * 信息
     */
    @Excel(name = "信息", width = 15)
    @ApiModelProperty(value = "信息")
    private String content;
    /**
     * 创建时间
     */
    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "发货单Id")
    private String sendOrderId;

    @ApiModelProperty(value = "物流公司")
    private String logisticsName;

    @ApiModelProperty(value = "操作人")
    private String createBy;


    @ApiModelProperty(value = "信息")
    @TableField(exist = false)
    private List<String> contentList;

    public List<String> getContentList() {
        if (Objects.equals(this.label, "修改订单") && this.content.length() > 0) {
            return Arrays.asList(this.content.split("。"));
        }
        return null;
    }
}
